<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>tomcat 安装 | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>tomcat 安装</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Tomcat/">Tomcat</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<a href="http://tomcat.apache.org/" target="_blank" rel="external">tomcat 官网</a></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;下载</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[root@192 ~]<span class="comment"># cd /usr/local/src</span></div><div class="line">[root@192 src]<span class="comment"># wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.0.M19/bin/apache-tomcat-9.0.0.M19.tar.gz</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;解压</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">[root@192 src]<span class="comment"># tar zxf apache-tomcat-9.0.0.M19.tar.gz </span></div><div class="line">[root@192 src]<span class="comment"># mv apache-tomcat-9.0.0.M19 /usr/local/tomcat</span></div><div class="line">[root@192 src]<span class="comment"># cp -pv /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat</span></div><div class="line"><span class="string">"/usr/local/tomcat/bin/catalina.sh"</span> -&gt; <span class="string">"/etc/init.d/tomcat"</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;编辑配置文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 src]<span class="comment"># vim /etc/init.d/tomcat</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;从第二行加如下配置</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#chkconfig: 2345 63 37</span></div><div class="line"><span class="comment">#description: tomcat server init script</span></div><div class="line"><span class="comment">#Source Function Library</span></div><div class="line">./etc/init.d/<span class="built_in">functions</span></div><div class="line">JAVA_HOME=/usr/<span class="built_in">local</span>/jdk1.8.0_111</div><div class="line">CATALINA_HOME=/usr/<span class="built_in">local</span>/tomcat</div></pre></td></tr></table></figure>
<p><figure class="figure"><img src="https://github.com/hcldirgit/image/blob/master/tomcat%20%E5%AE%89%E8%A3%85/01.png?raw=true" alt=""></figure></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;保存该文件，然后把 tomcat 加入服务列表里面。</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">[root@192 src]<span class="comment"># chmod 755 /etc/init.d/tomcat</span></div><div class="line">[root@192 src]<span class="comment"># chkconfig --add tomcat</span></div><div class="line">[root@192 src]<span class="comment"># chkconfig tomcat on</span></div><div class="line">[root@192 src]<span class="comment"># service tomcat start</span></div><div class="line">/etc/init.d/tomcat: line 5: ./etc/init.d/<span class="built_in">functions</span>: Permission denied</div><div class="line">Using CATALINA_BASE: /usr/<span class="built_in">local</span>/tomcat</div><div class="line">Using CATALINA_HOME: /usr/<span class="built_in">local</span>/tomcat</div><div class="line">Using CATALINA_TMPDIR: /usr/<span class="built_in">local</span>/tomcat/temp</div><div class="line">Using JRE_HOME: /usr/<span class="built_in">local</span>/jdk1.8.0_111</div><div class="line">Using CLASSPATH: /usr/<span class="built_in">local</span>/tomcat/bin/bootstrap.jar:/usr/<span class="built_in">local</span>/tomcat/bin/tomcat-juli.jar</div><div class="line">Tomcat started.</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;检测是否启动</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">[root@192 src]<span class="comment"># ps aux | grep tomcat</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在浏览器上输入 <a href="http://192.168.0.73:8080" target="_blank" rel="external">http://192.168.0.73:8080</a> 可以看到 tomcat 的欢迎页。</p>

	

	
		<span class="different-posts"><a href="/2017/10/12/Tomcat/2. tomcat 安装/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
